<?php

require_once('../include/GeneralTop.php');
require('../include/class/db.php');

if (!$content_admin) {
	die('<div style="text-align:center">Permission denied...</div>');
}

if ((isset($_POST["submit"]))) {
    $db = new db;
    $insertSQL = sprintf("INSERT INTO pethospital (vet_hospital, vet_city, vet_district, vet_address, vet_phone, 
							vet_maincontact, vet_mobilephone, vet_sspca_partner, preferential) 
							VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['txtHospital'], "text"),
                       GetSQLValueString($_POST['ddlCity'], "text"),
                       GetSQLValueString($_POST['ddlDistrict'], "text"),
                       GetSQLValueString($_POST['txtAddress'], "text"),
                       GetSQLValueString($_POST['txtPhone'], "text"),
                       GetSQLValueString($_POST['txtMainContact'], "text"),
                       GetSQLValueString($_POST['txtMobilePhone'], "text"),
                       GetSQLValueString($_POST['txtPartner'], "text"),
                       GetSQLValueString($_POST['spay_count'], "text"));

    $db->query($insertSQL);
    header("location:".$_SERVER['PHP_SELF']."?result=suc");
}

include('AdminPanel.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="form1" name="form1" method="POST">
  <table align="center">
    <?php
    if($_GET['result'] && 'suc' == $_GET['result']) {
    ?>
    <tr valign="baseline">
      <td colspan="2" nowrap="nowrap" align="center"><font color="green">添加成功...</font></td>
    </tr>
    <?php
    }
    ?>
    <tr>
      <th width="178" scope="row" align="right">宠物诊所/医院</th>
      <td width="215"><label>
        <input type="text" name="txtHospital" id="txtHospital" />
      </label></td>
    </tr>
    <tr>
      <th scope="row" align="right">城市
        </th>
      <td><label>
        <select name="ddlCity" id="ddlCity">
        <option value="上海市">上海市</option>
        </select>
      </label></td>
    </tr>
    <tr>
      <th scope="row" align="right">区县</th>
      <td><select name="ddlDistrict" id="ddlDistrict">
      	<option value="">-请选择-</option>
        <?php
        foreach($district_arr as $_key => $_value) {
        	echo '<option value="'.$_value.'">'.$_value.'</option>';
        }        
        ?>
      </select></td>
    </tr>
    <tr>
      <th scope="row" align="right">地址</th>
      <td><input type="text" name="txtAddress" id="txtAddress" /></td>
    </tr>
    <tr>
      <th scope="row" align="right">电话</th>
      <td><input type="text" name="txtPhone" id="txtPhone" /></td>
    </tr>
    <tr>
      <th scope="row" align="right">诊所联系人名字</th>
      <td><input type="text" name="txtMainContact" id="txtMainContact" /></td>
    </tr>
    <tr>
      <th scope="row" align="right">手机</th>
      <td><input type="text" name="txtMobilePhone" id="txtMobilePhone" /></td>
    </tr>
    <tr>
      <th scope="row" align="right">分会合作伙伴</th>
      <td>
      	<input type="radio" name="txtPartner" value="Y" id="txtPartner" /> 是  
      	<input type="radio" name="txtPartner" value="N" id="txtPartner" checked/> 否  	
      </td>
    </tr>
    <tr>
      <th scope="row" align="right" valign="top">合作优惠</th>
      <td><textarea name="spay_count" id="txt_spay_count" cols="50" rows="10"></textarea></td>
    </tr>
    <tr>
      <th scope="row">&nbsp;</th>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <th scope="row">&nbsp;</th>
      <td><label>
        <input type="submit" name="submit" id="submit" value="Submit" />&nbsp;&nbsp;
        <input type="button" id="button" onclick="window.location.href='ShowPetHospital.php'" value="Back">
      </label></td>
    </tr>
    <tr>
      <th scope="row">&nbsp;</th>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
</body>
</html>